﻿window.HTMLCanvasElement.prototype.getFile = function (name, type) {
	if (this.mozGetAsFile) {
		return this.mozGetAsFile(name, type);
	}
	else {
		var sBase64 = this.toDataURL(type, 1);
		var aBase64 = sBase64.split(',');

		var sData = atob(aBase64[1]);

		var aBufferView = new Uint8Array(sData.length);

		for (var i = 0; i < aBufferView.length; i++) {
			aBufferView[i] = sData.charCodeAt(i);
		}
		
		return new Blob([aBufferView], { type: 'application/octet-binary' });
	}
};